home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / cprog / tdddconv.lha / tddd2nff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-12  |  1.1 KB  |  50 lines

  1. /* tddd2nff.c - convert TDDD (or TTDDD) file to NFF file
  2.  *            - written by Glenn M. Lewis - 10/29/91
  3.  */
  4.  
  5. static char rcs_id[] = "$Id: tddd2nff.c,v 1.3 1991/10/30 08:13:57 glewis Exp glewis $";
  6.  
  7. #include <stdio.h>
  8. #include "ttdddlib.h"
  9.  
  10. main(argc, argv)
  11. int argc;
  12. char *argv[];
  13. {
  14.     char filename[256], rootname[256], *c1, *c2;
  15.     int i;
  16.     WORLD *world;
  17.     FILE *inp, *out;
  18.  
  19.     filename[0] = '\0';
  20.     rootname[0] = '\0';
  21.     for (i=1; i<argc; i++) {
  22.         if (argv[i][0] == '-') {
  23.             fprintf(stderr, "Unknown option '%s' ignored.\n", argv[i]);
  24.         } else if (filename[0]) {
  25.             strcpy(rootname, argv[i]);
  26.         } else {
  27.             strcpy(filename, argv[i]);    /* Make root of filename the default */
  28.             for (c1=rootname,c2=argv[i]; (*c1 = *c2++) && *c1!='.'; c1++) ;
  29.             *c1 = '\0';
  30.             strcat(rootname, ".nff");
  31.         }
  32.     }
  33.  
  34.     if (!filename[0]) inp = stdin;
  35.     else if (!(inp = fopen(filename, "r"))) {
  36.         fprintf(stderr, "Can't open '%s' for input.\n", filename);
  37.         exit(-1);
  38.     }
  39.     if (!rootname[0]) out = stdout;
  40.     else if (!(out = fopen(rootname, "w"))) {
  41.         fprintf(stderr, "Can't open '%s' for output.\n", rootname);
  42.         exit(-1);
  43.     }
  44.  
  45.     world = read_World(inp);
  46.     write_NFF(world, out);
  47.     exit(0);
  48. }
  49.  
  50.